% Fabian Wenzelmann, 2012
% For the documentation of the bfr package.

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{fullpage}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{plotmarks}
\usetikzlibrary{shapes,shadows,arrows}
\usetikzlibrary{calc}

\definecolor{shadecolor}{rgb}{.9,.9,1}

\newcommand{\nodeContent}{
\begin{tabular}{l}
\colorbox{shadecolor}{Child 1\hspace{2.125mm}}\\
\colorbox{shadecolor}{Child 2\hspace{2.125mm}}\\
\colorbox{shadecolor}{Parent 1}\\
\colorbox{shadecolor}{Parent 2}
\end{tabular}
}

\begin{document}
\pagestyle{empty}
\begin{center}
\scalebox{1.5}{
\begin{tikzpicture}
\tikzstyle{st_node} = [rectangle, rounded corners, draw=blue!60, rectangle split, rectangle split parts=2, anchor=north]
\node[st_node] (m) at (0, 0) {$\phi' \equiv x_2$
\nodepart{second}
\nodeContent
};

\def\rDist{4}
\def\uY{1.75}
\node[st_node] (cO) at (\rDist, \uY) {$\phi_1'' \equiv false$
\nodepart{second}
\nodeContent
};

\node[st_node] at (\rDist, -\uY) {$\phi_2'' \equiv true$
\nodepart{second}
\nodeContent
};

%\def\lDist{-4}
%\node[st_node] at (\lDist, \uY) {$\phi'_{P_1} \equiv x_1 \wedge x_2$
%\nodepart{second}
%\nodeContent
%};
%
%\node[st_node] at (\lDist, -\uY) {$\phi'_{P_2} \equiv x_1 \vee x_2$
%\nodepart{second}
%\nodeContent
%};

\def\posODist{-0.5}
\def\posTDist{\posODist - 0.06}
\def\posTTDist{\posTDist}
\def\posFDist{\posTTDist}

\def\rLabelDist{1.1}
\def\lLabelDist{-\rLabelDist}

\def\arrowXLength{1}
\def\arrowXLengthT{0.5}
\def\upperY{1}
\def\lowerY{-2.5}

\def\rBound{2.69}

% positions for main node
\def\mOPos{-0.6 + \posODist}
\def\mTPos{\mOPos + \posTDist}
\def\mTTPos{\mTPos + \posTTDist}
\def\mFPos{\mTTPos + \posFDist}

\draw[->, thick] (\rLabelDist, \mOPos) -- (\rLabelDist + \arrowXLength, \mOPos) |- (\rLabelDist + \arrowXLength, \upperY) |- (\rBound, \upperY);

\draw[->, thick] (\rLabelDist, \mTPos) -- (\rLabelDist + \arrowXLength, \mTPos) |- (\rLabelDist + \arrowXLength, \lowerY) |- (\rBound, \lowerY);

\def\rrLeft{3.05}
\def\rrLabel{5.1}

\def\cOOPos{\posODist + 1.1}
\def\cOTPos{\cOOPos + \posTDist}
\def\cOTTPos{\posODist}
\def\cOFPos{\cOTTPos + \posFDist}

\def\mRBound{1.3}

\draw[->, thick, dashed] (\rrLabel, \cOOPos) -- (\rrLabel + \arrowXLength, \cOOPos);
\draw[->, thick, dashed] (\rrLabel, \cOTPos) -- (\rrLabel + \arrowXLength, \cOTPos);
\draw[->, thick, dashed] (\rrLeft, \cOTTPos) -- (\rrLeft - \arrowXLength - \arrowXLengthT, \cOTTPos) |- (\rrLeft - \arrowXLength - \arrowXLengthT, \upperY);
\draw[->, thick] (\rrLeft, \cOFPos) -- (\rrLeft - 0.75, \cOFPos) |- (\rrLeft - 0.75, \cOFPos - 0.35) |- (\mRBound, \cOFPos - 0.35);

\def\cTOPos{\posODist - 2.4}
\def\cTTPos{\cTOPos + \posTDist}
\def\cTTTPos{\cTTPos + \posTTDist}
\def\cTFPos{\cTTTPos + \posFDist}
\draw[->, thick, dashed] (\rrLabel, \cTOPos) -- (\rrLabel + \arrowXLength, \cTOPos);
\draw[->, thick, dashed] (\rrLabel, \cTTPos) -- (\rrLabel + \arrowXLength, \cTTPos);
\draw[->, thick] (\rrLeft, \cTTTPos) -- (\rrLeft - \arrowXLength - \arrowXLengthT, \cTTTPos) |- (\rrLeft - \arrowXLength - \arrowXLengthT, \cTTTPos + 1.25) |- (\mRBound, \cTTTPos + 1.25);
\draw[->, thick, dashed] (\rrLeft, \cTFPos) -- (\rrLeft - \arrowXLength - \arrowXLengthT, \cTFPos) -| (\rrLeft - \arrowXLength - \arrowXLengthT, \cTFPos - 1.25);

\draw[->, thick, dashed] (-0.9, \mTTPos) -- (-0.9 - \arrowXLength, \mTTPos) |- +(0, 1.25);
\draw[->, thick, dashed] (-0.9, \mFPos) -- (-0.9 - \arrowXLength, \mFPos) -| +(0, -1.25);
\end{tikzpicture}
}
\end{center}

\end{document}
